package com.springcloud.feigndemoserver1000.service;

import com.springcloud.common.dto.PageDTO;
import com.springcloud.common.dto.ResponseData;
import com.springcloud.common.dto.UserDTO;
import com.springcloud.feigndemoserver1000.config.FeignInterceptorConfig;
import com.springcloud.feigndemoserver1000.service.impl.FeignUserServiceFallBackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;



@FeignClient(name="feign-demo-server1001" //fallbackFactory与fallback方法不能同时使用,当网络不通或者访问失败时会进入fallback的实现类容错逻辑
        /*,fallback = FeignUserServiceFallBack.class*/
        ,fallbackFactory = FeignUserServiceFallBackFactory.class

        )
public interface FeignUserService {

    /*
     * @Author ZhangBin
     * @Date 2020/6/30 14:01
     * @Description: 根据用户id获取用户信息
     *
     **/
    @GetMapping(value = "/user/getUserById/{userId}")
    ResponseData<UserDTO> getUserById(@PathVariable(name="userId") Integer id);

    /*
     * @Author ZhangBin
     * @Date 2020/6/30 14:08
     * @Description: 分页查询
     * GET请求+@RequestBody实现接口调用，必须使用HttpClient作为传输客户端，原生的UrlConnection和OkHttp都不支持
     * GET请求+POJO实现接口调用，必须使用HttpClient作为传输客户端，原生的UrlConnection和OkHttp都不支持
     **/
    @RequestMapping(value = "/user/getUserPage",method=RequestMethod.GET)
    ResponseData<PageDTO<UserDTO>> getUserPage(PageDTO pageDTO);


    /*
     * @Author ZhangBin
     * @Date 2020/8/19 16:22
     * @Description: Feign实现文件上传
     *
     **/
    @RequestMapping(value = "/user/fileUploadTest",
            method=RequestMethod.POST,
            consumes= {MediaType.MULTIPART_FORM_DATA_VALUE})
    ResponseData<?> fileUploadTest(@RequestPart(value = "file") MultipartFile file,@RequestParam(value = "remark") String remark);

    /*
     * @Author ZhangBin
     * @Date 2020/8/20 17:16
     * @Description: 图片流返回测试，如：图形验证码
     *
     **/
    @RequestMapping("/user/imgIOStreamTest")
    feign.Response imgIOStreamTest();




}
